﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.IO;

namespace WodManager.Funcionality
{
    public class Notepad
    {
        public List<Note> Notes;
        public void SerializeToXml(string filePath)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(Notepad));
            FileStream stream = File.Create(filePath);

            serializer.Serialize(stream, this);
            stream.Close();
        }

        public void DeserializeFromXml(string filePath)
        {
            if (File.Exists(filePath))
            {
                XmlSerializer serializer = new XmlSerializer(typeof(Notepad));
                FileStream stream = File.OpenRead(filePath);

                Notepad tmp = (Notepad)serializer.Deserialize(stream);
                this.Notes = tmp.Notes;
                stream.Close();
            }
        }

        public Notepad()
        {
            Notes = new List<Note>();
        }
    }
}
